const path = require('path');

function fromRoot(...paths) {
  let dirname = ''

  if (__dirname.includes('node_modules')) {
    dirname = __dirname.split('node_modules')[0]
  }

  if (__dirname.includes('script')) {
    dirname = __dirname.split('script')[0]
  }

  return path.join(dirname, ...paths.map(p => p.replace(/\//g, '\\'))).replace(/^file:\\/g, '');
}

exports.fromRoot = fromRoot;